/**
 * mongodb@2.x.x 可以，mongodb@3.0不可以了
 * @type {[type]}
 */
const MongoClient = require('mongodb').MongoClient
const assert = require('assert')

const url = 'mongodb://localhost:27017/bb'

MongoClient.connect(url, function (err, db) {
  assert.equal(null, err)
  console.log('Connected successfully to server')
  queryUsers(db, () => {
    db.close()
  })
})

function queryUsers (db, callback) {
  var collection = db.collection('users')
  collection.find({}).toArray(function (err, docs) {
    console.log('users...')
    console.log(docs)
    callback(docs)
  })
}